package com.ruoyi.web.controller.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.VideoReview;
import com.ruoyi.system.service.IVideoReviewService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 视频评论Controller
 * 
 * @author ruoyi
 * @date 2025-05-21
 */
@RestController
@RequestMapping("/system/review")
public class VideoReviewController extends BaseController
{
    @Autowired
    private IVideoReviewService videoReviewService;

    /**
     * 查询视频评论列表
     */
    @PreAuthorize("@ss.hasPermi('system:review:list')")
    @GetMapping("/list")
    public TableDataInfo list()
    {

        startPage();
//        System.err.println(222);
        List<VideoReview> list = videoReviewService.selectVideoReviewList();
        return getDataTable(list);
    }

    /**
     * 导出视频评论列表
     */
    @PreAuthorize("@ss.hasPermi('system:review:export')")
    @Log(title = "视频评论", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VideoReview videoReview)
    {
        List<VideoReview> list = videoReviewService.selectVideoReviewList();
        ExcelUtil<VideoReview> util = new ExcelUtil<VideoReview>(VideoReview.class);
        util.exportExcel(response, list, "视频评论数据");
    }

    /**
     * 获取视频评论详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:review:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(videoReviewService.selectVideoReviewById(id));
    }

    /**
     * 新增视频评论
     */
    @PreAuthorize("@ss.hasPermi('system:review:add')")
    @Log(title = "视频评论", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VideoReview videoReview)
    {
        System.out.println(videoReview);
        return toAjax(videoReviewService.insertVideoReview(videoReview));
    }


    /**
     * 删除视频评论
     */
    @PreAuthorize("@ss.hasPermi('system:review:remove')")
    @Log(title = "视频评论", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(videoReviewService.deleteVideoReviewByIds(ids));
    }
}
